import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
import { RoleService } from './service/role.service';
import { flyIn } from '../../common/animation/common.animation';
import { switchMap } from 'rxjs/operators';
@Component({
    templateUrl: './role-info.component.html',
    styleUrls: ['./role-info.component.scss'],
    animations: [flyIn]
})
export class RoleInfoComponent implements OnInit {
    role: any = {};
    constructor(
        private roleService: RoleService,
        private router: Router,
        private route: ActivatedRoute) { }

    ngOnInit(): void {
        this.route.paramMap.pipe(
            switchMap((params: ParamMap) => {
                this.role.roleId = +params.get('id');
                this.role.unitId = +params.get('unitId');
                return this.roleService.loadRoleById(this.role)
            })
        ).subscribe(data => this.role = data);
    }

}
